/*
 * JSGD.java
 *
 * Created on May 11, 2005, 10:51 AM
 */

package apletsecuge;

import SecuGen.FDxSDK.jni.*;
import java.awt.*;
import java.awt.image.*;
import javax.swing.*;


/**
 *
 * @author  Administrator
 */
public class JSGDApplet extends javax.swing.JDialog{
    
    //Private instance variables
    private long deviceName;
    private long devicePort;
    private JFPLib fplib = null;  
    private long ret;
    private boolean bLEDOn;
    private byte[] regMin1 = new byte[400];
    private byte[] regMin2 = new byte[400];
    private byte[] vrfMin  = new byte[400];
    private Image img;
    private FDxDeviceInfoParam deviceInfo = new FDxDeviceInfoParam();
    private BufferedImage imgRegistration1;
    private BufferedImage imgRegistration2;
    private BufferedImage imgVerification;
    private boolean r1Captured = false;
    private boolean r2Captured = false;
    private boolean v1Captured = false;
    
    
    /** Creates new form JSGD */
        
    public JSGDApplet(java.awt.Frame parent, boolean modal) {
        super(parent, modal);
        bLEDOn = false;
        initComponents();
        disableControls();
        this.jComboBoxRegisterSecurityLevel.setSelectedIndex(4);
        this.jComboBoxVerifySecurityLevel.setSelectedIndex(4);
    }
    
    //desactivar controles
    private void disableControls()
    {
        this.jButtonToggleLED.setEnabled(false);
        this.jButtonCapture.setEnabled(false);
        this.jButtonCaptureR1.setEnabled(false);
        this.jButtonCaptureR2.setEnabled(false);
        this.jButtonCaptureV1.setEnabled(false);
        this.jButtonRegister.setEnabled(false);
        this.jButtonVerify.setEnabled(false);
        this.jButtonSetBrightness.setEnabled(false);
        this.jButtonSetContrast.setEnabled(false);
        this.jButtonGetDeviceInfo.setEnabled(false);
        this.jButtonConfig.setEnabled(false);
        this.jButtonSetGain.setEnabled(false);
        this.jButtonClose.setEnabled(false);
        this.jButtonInit.setEnabled(true);
    }
    
    //activar controles
    private void enableControls()
    {
        this.jButtonToggleLED.setEnabled(true);
        this.jButtonCapture.setEnabled(true);
        this.jButtonCaptureR1.setEnabled(true);
        this.jButtonCaptureR2.setEnabled(true);
        this.jButtonCaptureV1.setEnabled(true);
        this.jButtonSetBrightness.setEnabled(true);
        this.jButtonSetContrast.setEnabled(true);
        this.jButtonGetDeviceInfo.setEnabled(true);
        this.jButtonConfig.setEnabled(true);
        this.jButtonSetGain.setEnabled(true);
        this.jButtonClose.setEnabled(true);
        this.jButtonInit.setEnabled(false);
     }
    
    //controles de registro y verificacion 
    private void enableRegisterAndVerifyControls()
    {
        if (r1Captured && r2Captured)
            this.jButtonRegister.setEnabled(true);
        if (r1Captured && r2Captured && v1Captured)
            this.jButtonVerify.setEnabled(true);
    }
    
    /** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        jLabelStatus = new javax.swing.JLabel();
        jTabbedPane1 = new javax.swing.JTabbedPane();
        jPanelImage = new javax.swing.JPanel();
        jButtonInit = new javax.swing.JButton();
        jLabelImage = new javax.swing.JLabel();
        jLabelOpenDevice = new javax.swing.JLabel();
        jLabelUSBID = new javax.swing.JLabel();
        jComboBoxUSBPort = new javax.swing.JComboBox();
        jLabelParallel = new javax.swing.JLabel();
        jComboBoxParallelPort = new javax.swing.JComboBox();
        jButtonToggleLED = new javax.swing.JButton();
        jButtonCapture = new javax.swing.JButton();
        jLabelSetBrightness = new javax.swing.JLabel();
        jComboBoxBrightness = new javax.swing.JComboBox();
        jButtonSetBrightness = new javax.swing.JButton();
        jLabelSetContrast = new javax.swing.JLabel();
        jComboBoxContrast = new javax.swing.JComboBox();
        jButtonSetContrast = new javax.swing.JButton();
        jButtonConfig = new javax.swing.JButton();
        jLabelSetGain = new javax.swing.JLabel();
        jComboBoxGain = new javax.swing.JComboBox();
        jButtonSetGain = new javax.swing.JButton();
        jPanelRegisterVerify = new javax.swing.JPanel();
        jLabelSecurityLevel = new javax.swing.JLabel();
        jLabelRegistration = new javax.swing.JLabel();
        jLabelVerification = new javax.swing.JLabel();
        jComboBoxRegisterSecurityLevel = new javax.swing.JComboBox();
        jComboBoxVerifySecurityLevel = new javax.swing.JComboBox();
        jLabelRegistrationBox = new javax.swing.JLabel();
        jLabelRegisterImage1 = new javax.swing.JLabel();
        jLabelRegisterImage2 = new javax.swing.JLabel();
        jLabelVerificationBox = new javax.swing.JLabel();
        jLabelVerifyImage = new javax.swing.JLabel();
        jButtonCaptureR1 = new javax.swing.JButton();
        jButtonCaptureV1 = new javax.swing.JButton();
        jButtonRegister = new javax.swing.JButton();
        jButtonVerify = new javax.swing.JButton();
        jButtonCaptureR2 = new javax.swing.JButton();
        jProgressBarR1 = new javax.swing.JProgressBar();
        jProgressBarR2 = new javax.swing.JProgressBar();
        jProgressBarV1 = new javax.swing.JProgressBar();
        jPanelDeviceInfo = new javax.swing.JPanel();
        jLabelDeviceInfoGroup = new javax.swing.JLabel();
        jLabelDeviceID = new javax.swing.JLabel();
        jTextFieldDeviceID = new javax.swing.JTextField();
        jLabelFWVersion = new javax.swing.JLabel();
        jTextFieldFWVersion = new javax.swing.JTextField();
        jLabelSerialNumber = new javax.swing.JLabel();
        jTextFieldSerialNumber = new javax.swing.JTextField();
        jLabelImageWidth = new javax.swing.JLabel();
        jTextFieldImageWidth = new javax.swing.JTextField();
        jLabelImageHeight = new javax.swing.JLabel();
        jTextFieldImageHeight = new javax.swing.JTextField();
        jLabelImageDPI = new javax.swing.JLabel();
        jTextFieldImageDPI = new javax.swing.JTextField();
        jLabelBrightness = new javax.swing.JLabel();
        jTextFieldBrightness = new javax.swing.JTextField();
        jLabelContrast = new javax.swing.JLabel();
        jTextFieldContrast = new javax.swing.JTextField();
        jLabelGain = new javax.swing.JLabel();
        jTextFieldGain = new javax.swing.JTextField();
        jButtonGetDeviceInfo = new javax.swing.JButton();
        jComboBoxDeviceName = new javax.swing.JComboBox();
        jLabelDeviceName = new javax.swing.JLabel();
        jLabelSpacer1 = new javax.swing.JLabel();
        jLabelSpacer2 = new javax.swing.JLabel();
        jButtonClose = new javax.swing.JButton();

        getContentPane().setLayout(new org.netbeans.lib.awtextra.AbsoluteLayout());

        jLabelStatus.setText("Click Initialize Button ...");
        jLabelStatus.setBorder(javax.swing.BorderFactory.createBevelBorder(javax.swing.border.BevelBorder.LOWERED));
        getContentPane().add(jLabelStatus, new org.netbeans.lib.awtextra.AbsoluteConstraints(10, 470, 380, 30));

        jPanelImage.setLayout(new org.netbeans.lib.awtextra.AbsoluteLayout());

        jButtonInit.setText("Initialize");
        jButtonInit.setMaximumSize(new java.awt.Dimension(100, 30));
        jButtonInit.setMinimumSize(new java.awt.Dimension(100, 30));
        jButtonInit.setName("jButtonInit"); // NOI18N
        jButtonInit.setPreferredSize(new java.awt.Dimension(100, 30));
        jButtonInit.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButtonInitActionPerformed(evt);
            }
        });
        jPanelImage.add(jButtonInit, new org.netbeans.lib.awtextra.AbsoluteConstraints(10, 10, 100, 30));

        jLabelImage.setBorder(javax.swing.BorderFactory.createBevelBorder(javax.swing.border.BevelBorder.LOWERED));
        jLabelImage.setMinimumSize(new java.awt.Dimension(260, 300));
        jLabelImage.setPreferredSize(new java.awt.Dimension(260, 300));
        jPanelImage.add(jLabelImage, new org.netbeans.lib.awtextra.AbsoluteConstraints(10, 60, -1, -1));

        jLabelOpenDevice.setBorder(javax.swing.BorderFactory.createTitledBorder("Open Device"));
        jPanelImage.add(jLabelOpenDevice, new org.netbeans.lib.awtextra.AbsoluteConstraints(280, 50, 190, 130));

        jLabelUSBID.setText("USB ID");
        jPanelImage.add(jLabelUSBID, new org.netbeans.lib.awtextra.AbsoluteConstraints(292, 70, 180, -1));

        jComboBoxUSBPort.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "AUTO_DETECT", "0", "1", "2", "3", "4", "5", "6", "7", "8", "9" }));
        jComboBoxUSBPort.setMaximumSize(new java.awt.Dimension(170, 27));
        jComboBoxUSBPort.setMinimumSize(new java.awt.Dimension(170, 27));
        jComboBoxUSBPort.setPreferredSize(new java.awt.Dimension(170, 27));
        jPanelImage.add(jComboBoxUSBPort, new org.netbeans.lib.awtextra.AbsoluteConstraints(290, 90, 170, 27));

        jLabelParallel.setText("Parallel");
        jPanelImage.add(jLabelParallel, new org.netbeans.lib.awtextra.AbsoluteConstraints(292, 120, 180, -1));

        jComboBoxParallelPort.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "AUTO_DETECT", "LPT1_378", "LPT2_278", "LPT3_3BC" }));
        jComboBoxParallelPort.setMaximumSize(new java.awt.Dimension(170, 27));
        jComboBoxParallelPort.setMinimumSize(new java.awt.Dimension(170, 27));
        jComboBoxParallelPort.setPreferredSize(new java.awt.Dimension(170, 27));
        jPanelImage.add(jComboBoxParallelPort, new org.netbeans.lib.awtextra.AbsoluteConstraints(290, 140, 170, 27));

        jButtonToggleLED.setText("Toggle LED");
        jButtonToggleLED.setMaximumSize(new java.awt.Dimension(100, 30));
        jButtonToggleLED.setMinimumSize(new java.awt.Dimension(100, 30));
        jButtonToggleLED.setPreferredSize(new java.awt.Dimension(100, 30));
        jButtonToggleLED.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButtonToggleLEDActionPerformed(evt);
            }
        });
        jPanelImage.add(jButtonToggleLED, new org.netbeans.lib.awtextra.AbsoluteConstraints(120, 10, 100, 30));

        jButtonCapture.setText("Capture");
        jButtonCapture.setMaximumSize(new java.awt.Dimension(100, 30));
        jButtonCapture.setMinimumSize(new java.awt.Dimension(100, 30));
        jButtonCapture.setPreferredSize(new java.awt.Dimension(100, 30));
        jButtonCapture.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButtonCaptureActionPerformed(evt);
            }
        });
        jPanelImage.add(jButtonCapture, new org.netbeans.lib.awtextra.AbsoluteConstraints(230, 10, 100, 30));

        jLabelSetBrightness.setBorder(javax.swing.BorderFactory.createTitledBorder("Brightness"));
        jPanelImage.add(jLabelSetBrightness, new org.netbeans.lib.awtextra.AbsoluteConstraints(280, 180, 190, 60));

        jComboBoxBrightness.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "0", "1", "2", "3", "4", "5", "6", "7", "8", "9", "10", "11", "12", "13", "14", "15", "16", "17", "18", "19", "20", "21", "22", "23", "24", "25", "26", "27", "28", "29", "30", "31", "32", "33", "34", "35", "36", "37", "38", "39", "40", "41", "42", "43", "44", "45", "46", "47", "48", "49", "50", "51", "52", "53", "54", "55", "56", "57", "58", "59", "60", "61", "62", "63", "64", "65", "66", "67", "68", "69", "70", "71", "72", "73", "74", "75", "76", "77", "78", "79", "80", "81", "82", "83", "84", "85", "86", "87", "88", "89", "90", "91", "92", "93", "94", "95", "96", "97", "98", "99", "100" }));
        jComboBoxBrightness.setMaximumSize(new java.awt.Dimension(60, 27));
        jComboBoxBrightness.setMinimumSize(new java.awt.Dimension(60, 27));
        jComboBoxBrightness.setPreferredSize(new java.awt.Dimension(60, 27));
        jComboBoxBrightness.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jComboBoxBrightnessActionPerformed(evt);
            }
        });
        jPanelImage.add(jComboBoxBrightness, new org.netbeans.lib.awtextra.AbsoluteConstraints(290, 203, 60, 27));

        jButtonSetBrightness.setText("Apply");
        jButtonSetBrightness.setMaximumSize(new java.awt.Dimension(90, 30));
        jButtonSetBrightness.setMinimumSize(new java.awt.Dimension(90, 30));
        jButtonSetBrightness.setPreferredSize(new java.awt.Dimension(90, 30));
        jButtonSetBrightness.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButtonSetBrightnessActionPerformed(evt);
            }
        });
        jPanelImage.add(jButtonSetBrightness, new org.netbeans.lib.awtextra.AbsoluteConstraints(360, 200, 90, 30));

        jLabelSetContrast.setBorder(javax.swing.BorderFactory.createTitledBorder("Contrast"));
        jPanelImage.add(jLabelSetContrast, new org.netbeans.lib.awtextra.AbsoluteConstraints(280, 240, 190, 60));

        jComboBoxContrast.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "0", "1", "2", "3", "4", "5", "6", "7", "8", "9", "10", "11", "12", "13", "14", "15", "16", "17", "18", "19", "20", "21", "22", "23", "24", "25", "26", "27", "28", "29", "30", "31", "32", "33", "34", "35", "36", "37", "38", "39", "40", "41", "42", "43", "44", "45", "46", "47", "48", "49", "50", "51", "52", "53", "54", "55", "56", "57", "58", "59", "60", "61", "62", "63", "64", "65", "66", "67", "68", "69", "70", "71", "72", "73", "74", "75", "76", "77", "78", "79", "80", "81", "82", "83", "84", "85", "86", "87", "88", "89", "90", "91", "92", "93", "94", "95", "96", "97", "98", "99", "100" }));
        jComboBoxContrast.setMaximumSize(new java.awt.Dimension(60, 27));
        jComboBoxContrast.setMinimumSize(new java.awt.Dimension(60, 27));
        jComboBoxContrast.setPreferredSize(new java.awt.Dimension(60, 27));
        jPanelImage.add(jComboBoxContrast, new org.netbeans.lib.awtextra.AbsoluteConstraints(290, 263, 60, 27));

        jButtonSetContrast.setText("Apply");
        jButtonSetContrast.setMaximumSize(new java.awt.Dimension(90, 30));
        jButtonSetContrast.setMinimumSize(new java.awt.Dimension(90, 30));
        jButtonSetContrast.setPreferredSize(new java.awt.Dimension(90, 30));
        jButtonSetContrast.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButtonSetContrastActionPerformed(evt);
            }
        });
        jPanelImage.add(jButtonSetContrast, new org.netbeans.lib.awtextra.AbsoluteConstraints(360, 260, 90, 30));

        jButtonConfig.setText("Config");
        jButtonConfig.setMaximumSize(new java.awt.Dimension(100, 30));
        jButtonConfig.setMinimumSize(new java.awt.Dimension(100, 30));
        jButtonConfig.setPreferredSize(new java.awt.Dimension(100, 30));
        jButtonConfig.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButtonConfigActionPerformed(evt);
            }
        });
        jPanelImage.add(jButtonConfig, new org.netbeans.lib.awtextra.AbsoluteConstraints(340, 10, -1, 30));

        jLabelSetGain.setBorder(javax.swing.BorderFactory.createTitledBorder("Gain"));
        jPanelImage.add(jLabelSetGain, new org.netbeans.lib.awtextra.AbsoluteConstraints(280, 300, 190, 60));

        jComboBoxGain.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "1", "2" }));
        jComboBoxGain.setMaximumSize(new java.awt.Dimension(60, 27));
        jComboBoxGain.setMinimumSize(new java.awt.Dimension(60, 27));
        jComboBoxGain.setPreferredSize(new java.awt.Dimension(60, 27));
        jPanelImage.add(jComboBoxGain, new org.netbeans.lib.awtextra.AbsoluteConstraints(290, 323, 60, 27));

        jButtonSetGain.setText("Apply");
        jButtonSetGain.setMaximumSize(new java.awt.Dimension(90, 30));
        jButtonSetGain.setMinimumSize(new java.awt.Dimension(90, 30));
        jButtonSetGain.setPreferredSize(new java.awt.Dimension(90, 30));
        jButtonSetGain.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButtonSetGainActionPerformed(evt);
            }
        });
        jPanelImage.add(jButtonSetGain, new org.netbeans.lib.awtextra.AbsoluteConstraints(360, 320, 90, 30));

        jTabbedPane1.addTab("Image", jPanelImage);

        jPanelRegisterVerify.setLayout(new org.netbeans.lib.awtextra.AbsoluteLayout());

        jLabelSecurityLevel.setBorder(javax.swing.BorderFactory.createTitledBorder("Security Level"));
        jPanelRegisterVerify.add(jLabelSecurityLevel, new org.netbeans.lib.awtextra.AbsoluteConstraints(10, 10, 460, 60));

        jLabelRegistration.setText("Registration");
        jPanelRegisterVerify.add(jLabelRegistration, new org.netbeans.lib.awtextra.AbsoluteConstraints(20, 34, -1, -1));

        jLabelVerification.setText("Verification");
        jPanelRegisterVerify.add(jLabelVerification, new org.netbeans.lib.awtextra.AbsoluteConstraints(250, 34, -1, -1));

        jComboBoxRegisterSecurityLevel.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "LOWEST", "LOWER", "LOW", "BELOW_NORMAL", "NORMAL", "ABOVE_NORMAL", "HIGH", "HIGHER", "HIGHEST" }));
        jPanelRegisterVerify.add(jComboBoxRegisterSecurityLevel, new org.netbeans.lib.awtextra.AbsoluteConstraints(100, 30, 130, -1));

        jComboBoxVerifySecurityLevel.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "LOWEST", "LOWER", "LOW", "BELOW_NORMAL", "NORMAL", "ABOVE_NORMAL", "HIGH", "HIGHER", "HIGHEST" }));
        jPanelRegisterVerify.add(jComboBoxVerifySecurityLevel, new org.netbeans.lib.awtextra.AbsoluteConstraints(325, 30, 130, -1));

        jLabelRegistrationBox.setBorder(javax.swing.BorderFactory.createTitledBorder("Registration"));
        jPanelRegisterVerify.add(jLabelRegistrationBox, new org.netbeans.lib.awtextra.AbsoluteConstraints(10, 80, 290, 250));

        jLabelRegisterImage1.setBorder(javax.swing.BorderFactory.createBevelBorder(javax.swing.border.BevelBorder.LOWERED));
        jLabelRegisterImage1.setMinimumSize(new java.awt.Dimension(130, 150));
        jLabelRegisterImage1.setPreferredSize(new java.awt.Dimension(130, 150));
        jPanelRegisterVerify.add(jLabelRegisterImage1, new org.netbeans.lib.awtextra.AbsoluteConstraints(20, 100, -1, -1));

        jLabelRegisterImage2.setBorder(javax.swing.BorderFactory.createBevelBorder(javax.swing.border.BevelBorder.LOWERED));
        jLabelRegisterImage2.setMinimumSize(new java.awt.Dimension(130, 150));
        jLabelRegisterImage2.setPreferredSize(new java.awt.Dimension(130, 150));
        jPanelRegisterVerify.add(jLabelRegisterImage2, new org.netbeans.lib.awtextra.AbsoluteConstraints(160, 100, -1, -1));

        jLabelVerificationBox.setBorder(javax.swing.BorderFactory.createTitledBorder("Verification"));
        jPanelRegisterVerify.add(jLabelVerificationBox, new org.netbeans.lib.awtextra.AbsoluteConstraints(320, 80, 150, 250));

        jLabelVerifyImage.setBorder(javax.swing.BorderFactory.createBevelBorder(javax.swing.border.BevelBorder.LOWERED));
        jLabelVerifyImage.setMinimumSize(new java.awt.Dimension(130, 150));
        jLabelVerifyImage.setPreferredSize(new java.awt.Dimension(130, 150));
        jPanelRegisterVerify.add(jLabelVerifyImage, new org.netbeans.lib.awtextra.AbsoluteConstraints(330, 100, -1, -1));

        jButtonCaptureR1.setText("Capture R1");
        jButtonCaptureR1.setActionCommand("jButton1");
        jButtonCaptureR1.setMaximumSize(new java.awt.Dimension(130, 30));
        jButtonCaptureR1.setMinimumSize(new java.awt.Dimension(130, 30));
        jButtonCaptureR1.setPreferredSize(new java.awt.Dimension(130, 30));
        jButtonCaptureR1.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButtonCaptureR1ActionPerformed(evt);
            }
        });
        jPanelRegisterVerify.add(jButtonCaptureR1, new org.netbeans.lib.awtextra.AbsoluteConstraints(20, 280, 130, 30));

        jButtonCaptureV1.setText("Capture V1");
        jButtonCaptureV1.setActionCommand("jButton1");
        jButtonCaptureV1.setMaximumSize(new java.awt.Dimension(130, 30));
        jButtonCaptureV1.setMinimumSize(new java.awt.Dimension(130, 30));
        jButtonCaptureV1.setPreferredSize(new java.awt.Dimension(130, 30));
        jButtonCaptureV1.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButtonCaptureV1ActionPerformed(evt);
            }
        });
        jPanelRegisterVerify.add(jButtonCaptureV1, new org.netbeans.lib.awtextra.AbsoluteConstraints(330, 280, 130, 30));

        jButtonRegister.setText("Register");
        jButtonRegister.setActionCommand("jButton1");
        jButtonRegister.setMaximumSize(new java.awt.Dimension(270, 30));
        jButtonRegister.setMinimumSize(new java.awt.Dimension(270, 30));
        jButtonRegister.setPreferredSize(new java.awt.Dimension(270, 30));
        jButtonRegister.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButtonRegisterActionPerformed(evt);
            }
        });
        jPanelRegisterVerify.add(jButtonRegister, new org.netbeans.lib.awtextra.AbsoluteConstraints(20, 340, 270, 30));

        jButtonVerify.setText("Verify");
        jButtonVerify.setActionCommand("jButton1");
        jButtonVerify.setMaximumSize(new java.awt.Dimension(130, 30));
        jButtonVerify.setMinimumSize(new java.awt.Dimension(130, 30));
        jButtonVerify.setPreferredSize(new java.awt.Dimension(130, 30));
        jButtonVerify.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButtonVerifyActionPerformed(evt);
            }
        });
        jPanelRegisterVerify.add(jButtonVerify, new org.netbeans.lib.awtextra.AbsoluteConstraints(330, 340, 130, 30));

        jButtonCaptureR2.setText("Capture R2");
        jButtonCaptureR2.setActionCommand("jButton1");
        jButtonCaptureR2.setMaximumSize(new java.awt.Dimension(130, 30));
        jButtonCaptureR2.setMinimumSize(new java.awt.Dimension(130, 30));
        jButtonCaptureR2.setPreferredSize(new java.awt.Dimension(130, 30));
        jButtonCaptureR2.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButtonCaptureR2ActionPerformed(evt);
            }
        });
        jPanelRegisterVerify.add(jButtonCaptureR2, new org.netbeans.lib.awtextra.AbsoluteConstraints(160, 280, 130, 30));

        jProgressBarR1.setForeground(new java.awt.Color(0, 51, 153));
        jPanelRegisterVerify.add(jProgressBarR1, new org.netbeans.lib.awtextra.AbsoluteConstraints(20, 250, 130, -1));

        jProgressBarR2.setForeground(new java.awt.Color(0, 51, 153));
        jPanelRegisterVerify.add(jProgressBarR2, new org.netbeans.lib.awtextra.AbsoluteConstraints(160, 250, 130, -1));

        jProgressBarV1.setForeground(new java.awt.Color(0, 51, 153));
        jPanelRegisterVerify.add(jProgressBarV1, new org.netbeans.lib.awtextra.AbsoluteConstraints(330, 250, 130, -1));

        jTabbedPane1.addTab("Register/Verify", jPanelRegisterVerify);

        jPanelDeviceInfo.setLayout(new org.netbeans.lib.awtextra.AbsoluteLayout());

        jLabelDeviceInfoGroup.setBorder(javax.swing.BorderFactory.createTitledBorder("DeviceInfo"));
        jPanelDeviceInfo.add(jLabelDeviceInfoGroup, new org.netbeans.lib.awtextra.AbsoluteConstraints(10, 10, 290, 290));

        jLabelDeviceID.setText("Device ID");
        jPanelDeviceInfo.add(jLabelDeviceID, new org.netbeans.lib.awtextra.AbsoluteConstraints(30, 30, -1, -1));

        jTextFieldDeviceID.setEditable(false);
        jTextFieldDeviceID.setBorder(javax.swing.BorderFactory.createBevelBorder(javax.swing.border.BevelBorder.LOWERED));
        jPanelDeviceInfo.add(jTextFieldDeviceID, new org.netbeans.lib.awtextra.AbsoluteConstraints(120, 30, 160, -1));

        jLabelFWVersion.setText("F/W Version");
        jPanelDeviceInfo.add(jLabelFWVersion, new org.netbeans.lib.awtextra.AbsoluteConstraints(30, 60, -1, -1));

        jTextFieldFWVersion.setEditable(false);
        jTextFieldFWVersion.setBorder(javax.swing.BorderFactory.createBevelBorder(javax.swing.border.BevelBorder.LOWERED));
        jPanelDeviceInfo.add(jTextFieldFWVersion, new org.netbeans.lib.awtextra.AbsoluteConstraints(120, 60, 160, -1));

        jLabelSerialNumber.setText("Serial #");
        jPanelDeviceInfo.add(jLabelSerialNumber, new org.netbeans.lib.awtextra.AbsoluteConstraints(30, 90, -1, -1));

        jTextFieldSerialNumber.setEditable(false);
        jTextFieldSerialNumber.setBorder(javax.swing.BorderFactory.createBevelBorder(javax.swing.border.BevelBorder.LOWERED));
        jPanelDeviceInfo.add(jTextFieldSerialNumber, new org.netbeans.lib.awtextra.AbsoluteConstraints(120, 90, 160, -1));

        jLabelImageWidth.setText("Image Width");
        jPanelDeviceInfo.add(jLabelImageWidth, new org.netbeans.lib.awtextra.AbsoluteConstraints(30, 120, -1, -1));

        jTextFieldImageWidth.setEditable(false);
        jTextFieldImageWidth.setBorder(javax.swing.BorderFactory.createBevelBorder(javax.swing.border.BevelBorder.LOWERED));
        jPanelDeviceInfo.add(jTextFieldImageWidth, new org.netbeans.lib.awtextra.AbsoluteConstraints(120, 120, 160, -1));

        jLabelImageHeight.setText("Image Height");
        jPanelDeviceInfo.add(jLabelImageHeight, new org.netbeans.lib.awtextra.AbsoluteConstraints(30, 150, -1, -1));

        jTextFieldImageHeight.setEditable(false);
        jTextFieldImageHeight.setBorder(javax.swing.BorderFactory.createBevelBorder(javax.swing.border.BevelBorder.LOWERED));
        jPanelDeviceInfo.add(jTextFieldImageHeight, new org.netbeans.lib.awtextra.AbsoluteConstraints(120, 150, 160, -1));

        jLabelImageDPI.setText("Image DPI");
        jPanelDeviceInfo.add(jLabelImageDPI, new org.netbeans.lib.awtextra.AbsoluteConstraints(30, 180, -1, -1));

        jTextFieldImageDPI.setEditable(false);
        jTextFieldImageDPI.setBorder(javax.swing.BorderFactory.createBevelBorder(javax.swing.border.BevelBorder.LOWERED));
        jPanelDeviceInfo.add(jTextFieldImageDPI, new org.netbeans.lib.awtextra.AbsoluteConstraints(120, 180, 160, -1));

        jLabelBrightness.setText("Brightness");
        jPanelDeviceInfo.add(jLabelBrightness, new org.netbeans.lib.awtextra.AbsoluteConstraints(30, 210, -1, -1));

        jTextFieldBrightness.setEditable(false);
        jTextFieldBrightness.setBorder(javax.swing.BorderFactory.createBevelBorder(javax.swing.border.BevelBorder.LOWERED));
        jPanelDeviceInfo.add(jTextFieldBrightness, new org.netbeans.lib.awtextra.AbsoluteConstraints(120, 210, 160, -1));

        jLabelContrast.setText("Contrast");
        jPanelDeviceInfo.add(jLabelContrast, new org.netbeans.lib.awtextra.AbsoluteConstraints(30, 240, -1, -1));

        jTextFieldContrast.setEditable(false);
        jTextFieldContrast.setBorder(javax.swing.BorderFactory.createBevelBorder(javax.swing.border.BevelBorder.LOWERED));
        jPanelDeviceInfo.add(jTextFieldContrast, new org.netbeans.lib.awtextra.AbsoluteConstraints(120, 240, 160, -1));

        jLabelGain.setText("Gain");
        jPanelDeviceInfo.add(jLabelGain, new org.netbeans.lib.awtextra.AbsoluteConstraints(30, 270, -1, -1));

        jTextFieldGain.setEditable(false);
        jTextFieldGain.setBorder(javax.swing.BorderFactory.createBevelBorder(javax.swing.border.BevelBorder.LOWERED));
        jPanelDeviceInfo.add(jTextFieldGain, new org.netbeans.lib.awtextra.AbsoluteConstraints(120, 270, 160, -1));

        jButtonGetDeviceInfo.setText("Get Device Info");
        jButtonGetDeviceInfo.setMaximumSize(new java.awt.Dimension(150, 30));
        jButtonGetDeviceInfo.setMinimumSize(new java.awt.Dimension(150, 30));
        jButtonGetDeviceInfo.setPreferredSize(new java.awt.Dimension(150, 30));
        jButtonGetDeviceInfo.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButtonGetDeviceInfoActionPerformed(evt);
            }
        });
        jPanelDeviceInfo.add(jButtonGetDeviceInfo, new org.netbeans.lib.awtextra.AbsoluteConstraints(320, 20, 150, 30));

        jTabbedPane1.addTab("Device Info", jPanelDeviceInfo);

        getContentPane().add(jTabbedPane1, new org.netbeans.lib.awtextra.AbsoluteConstraints(10, 35, 500, 420));

        jComboBoxDeviceName.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "USB", "Parallel", "CN_FDU01", "CN_FDP01", "CN_FDU02", "CN_FDP02" }));
        jComboBoxDeviceName.setMinimumSize(new java.awt.Dimension(350, 10));
        jComboBoxDeviceName.setVerifyInputWhenFocusTarget(false);
        jComboBoxDeviceName.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jComboBoxDeviceNameActionPerformed(evt);
            }
        });
        getContentPane().add(jComboBoxDeviceName, new org.netbeans.lib.awtextra.AbsoluteConstraints(130, 10, 350, -1));

        jLabelDeviceName.setText("Device Name");
        getContentPane().add(jLabelDeviceName, new org.netbeans.lib.awtextra.AbsoluteConstraints(10, 11, 110, -1));

        jLabelSpacer1.setText(" ");
        getContentPane().add(jLabelSpacer1, new org.netbeans.lib.awtextra.AbsoluteConstraints(510, 490, 10, -1));

        jLabelSpacer2.setText(" ");
        getContentPane().add(jLabelSpacer2, new org.netbeans.lib.awtextra.AbsoluteConstraints(510, 10, 10, -1));

        jButtonClose.setText("Close");
        jButtonClose.setMaximumSize(new java.awt.Dimension(90, 30));
        jButtonClose.setMinimumSize(new java.awt.Dimension(90, 30));
        jButtonClose.setPreferredSize(new java.awt.Dimension(90, 30));
        jButtonClose.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButtonCloseActionPerformed(evt);
            }
        });
        getContentPane().add(jButtonClose, new org.netbeans.lib.awtextra.AbsoluteConstraints(410, 470, -1, -1));
    }// </editor-fold>//GEN-END:initComponents

    //boton cerrar
    private void jButtonCloseActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButtonCloseActionPerformed
        // TODO add your handling code here:
        long iError;
        iError = fplib.close();
         if (iError == FDxError.ERROR_NONE)
         {
            this.jLabelStatus.setText( "close() Success");
            this.disableControls();
            this.jTabbedPane1.setSelectedIndex(0);
         }
         else
            this.jLabelStatus.setText( "close() Error : " + iError);
        
    }//GEN-LAST:event_jButtonCloseActionPerformed

    //botn gain
    private void jButtonSetGainActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButtonSetGainActionPerformed
        long iError;
        iError = fplib.setGain(this.jComboBoxGain.getSelectedIndex()+1);
         if (iError == FDxError.ERROR_NONE)
         {
            this.jLabelStatus.setText( "setGain() Success");
            this.jTextFieldGain.setText(new String(Integer.toString(this.jComboBoxGain.getSelectedIndex()+1)));
         }
         else
            this.jLabelStatus.setText( "setGain() Error : " + iError);
        
    }//GEN-LAST:event_jButtonSetGainActionPerformed

    //informacion del dispositivo
    private void jButtonGetDeviceInfoActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButtonGetDeviceInfoActionPerformed
        // TODO add your handling code here:
        long iError;
        iError = fplib.getDeviceInfo(deviceInfo);
        if (ret == FDxError.ERROR_NONE)
        {
            this.jLabelStatus.setText( "getDeviceInfo() Success");
            this.jTextFieldSerialNumber.setText(new String(deviceInfo.deviceSN()));
            this.jTextFieldBrightness.setText(new String(Integer.toString(deviceInfo.brightness)));
            this.jTextFieldContrast.setText(new String(Integer.toString((int)deviceInfo.contrast)));
            this.jTextFieldDeviceID.setText(new String(Integer.toString(deviceInfo.deviceID)));
            this.jTextFieldFWVersion.setText(new String(Integer.toHexString(deviceInfo.FWVersion)));
            this.jTextFieldGain.setText(new String(Integer.toString(deviceInfo.gain)));
            this.jTextFieldImageDPI.setText(new String(Integer.toString(deviceInfo.imageDPI)));
            this.jTextFieldImageHeight.setText(new String(Integer.toString(deviceInfo.imageHeight)));
            this.jTextFieldImageWidth.setText(new String(Integer.toString(deviceInfo.imageWidth)));
            this.jComboBoxBrightness.setSelectedIndex(deviceInfo.brightness);
            this.jComboBoxContrast.setSelectedIndex(deviceInfo.contrast);
            this.jComboBoxGain.setSelectedIndex(deviceInfo.gain-1);
        }
         else
            this.jLabelStatus.setText( "getDeviceInfo() Error : " + iError);
         
    }//GEN-LAST:event_jButtonGetDeviceInfoActionPerformed

    //boton configurar
    private void jButtonConfigActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButtonConfigActionPerformed
        long iError;
        iError = fplib.configure(0);
         if (iError == FDxError.ERROR_NONE)
         {
            this.jLabelStatus.setText( "configure() Success");
           this.jButtonGetDeviceInfo.doClick();
         }
         else if (iError == FDxError.ERROR_NOT_USED)
            this.jLabelStatus.setText( "configure() not supported on this platform");
         else
            this.jLabelStatus.setText( "configure() Error : " + iError);
        
        
    }//GEN-LAST:event_jButtonConfigActionPerformed

    //boton de contraste
    private void jButtonSetContrastActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButtonSetContrastActionPerformed
        // TODO add your handling code here:
        long iError;
        iError = fplib.setContrast(this.jComboBoxContrast.getSelectedIndex());
         if (iError == FDxError.ERROR_NONE)
         {
            this.jLabelStatus.setText( "setContrast() Success");
            this.jTextFieldContrast.setText(new String(Integer.toString(this.jComboBoxContrast.getSelectedIndex())));
         }
         else
            this.jLabelStatus.setText( "setContrast() Error : " + iError);
        
        
    }//GEN-LAST:event_jButtonSetContrastActionPerformed

    //boton brigets
    private void jButtonSetBrightnessActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButtonSetBrightnessActionPerformed
        // TODO add your handling code here:
        long iError;
        iError = fplib.setBrightness(this.jComboBoxBrightness.getSelectedIndex());
         if (iError == FDxError.ERROR_NONE)
         {
            this.jLabelStatus.setText( "setBrightness() Success");
            this.jTextFieldBrightness.setText(new String(Integer.toString(this.jComboBoxBrightness.getSelectedIndex())));
         }
         else
            this.jLabelStatus.setText( "setBrightness() Error : " + iError);
        
    }//GEN-LAST:event_jButtonSetBrightnessActionPerformed

    private void jComboBoxBrightnessActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jComboBoxBrightnessActionPerformed
        // TODO add your handling code here:
    }//GEN-LAST:event_jComboBoxBrightnessActionPerformed

    //botn verificar..... FALTA
    private void jButtonVerifyActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButtonVerifyActionPerformed
        // TODO add your handling code here:
         long iError;
         long secuLevel = (long) (this.jComboBoxVerifySecurityLevel.getSelectedIndex() + 1);
         
         iError = fplib.matchForVerificationEx(regMin1,regMin2, vrfMin, secuLevel);

         if (iError == FDxError.ERROR_NONE)
            this.jLabelStatus.setText( "Verification Success");
         else
            this.jLabelStatus.setText( "MatchForVerificationEx() Error : " + iError);
        
    }//GEN-LAST:event_jButtonVerifyActionPerformed

    //BOTON REGISTRAR ... FALTA
    private void jButtonRegisterActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButtonRegisterActionPerformed
        // TODO add your handling code here:
         int[] matchScore = new int[1];
         long iError;
         long secuLevel = (long) (this.jComboBoxRegisterSecurityLevel.getSelectedIndex() + 1);
         //System.out.println("Security level = " + secuLevel);
         iError = fplib.matchForRegister(regMin1,regMin2, secuLevel); 

         matchScore[0] = 0;
         fplib.getMatchingScore(regMin1, regMin2, matchScore);

         if (iError == FDxError.ERROR_NONE)
            this.jLabelStatus.setText( "Registration Success, Matching Score: " + matchScore[0]);
         else
            this.jLabelStatus.setText( "MatchForRegister() Error : " + iError);
        
    }//GEN-LAST:event_jButtonRegisterActionPerformed
 
    //BOTON CAPTURE V1 ... FALTA
    private void jButtonCaptureV1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButtonCaptureV1ActionPerformed
        // TODO add your handling code here:
        int[] quality = new int[1];
        byte[] imageBuffer1 = ((java.awt.image.DataBufferByte) imgVerification.getRaster().getDataBuffer()).getData();
        long iError = FDxError.ERROR_NONE;
         
        iError = fplib.getImage(imageBuffer1);
        int img_qlty = 0;
        
        fplib.getImageQuality(deviceInfo.imageWidth, deviceInfo.imageHeight, imageBuffer1, quality); 
        this.jProgressBarV1.setValue(quality[0]);

        if (iError == FDxError.ERROR_NONE)
        {            
            this.jLabelVerifyImage.setIcon(new ImageIcon(imgVerification.getScaledInstance(130,150,Image.SCALE_DEFAULT)));
            this.jLabelStatus.setText("getImage() Success [" + ret + "]"); 
             
            iError = fplib.getMinutiae(imageBuffer1, vrfMin);
            if (iError == FDxError.ERROR_NONE)
            {
               this.jLabelStatus.setText("verification image was captured");
               v1Captured = true;
               this.enableRegisterAndVerifyControls();
            }
            else
               this.jLabelStatus.setText("GetMinutiae() Error : " + iError);
         }
         else
            this.jLabelStatus.setText("GetImage() Error : " + iError);
        
        
    }//GEN-LAST:event_jButtonCaptureV1ActionPerformed
    //BOTON CAPTURE R2 ... FALTA
    private void jButtonCaptureR2ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButtonCaptureR2ActionPerformed
        // TODO add your handling code here:
        
        int[] quality = new int[1];
        byte[] imageBuffer1 = ((java.awt.image.DataBufferByte) imgRegistration2.getRaster().getDataBuffer()).getData();
        long iError = FDxError.ERROR_NONE;
         
        iError = fplib.getImage(imageBuffer1);
        int img_qlty = 0;
        
        fplib.getImageQuality(deviceInfo.imageWidth, deviceInfo.imageHeight, imageBuffer1, quality); 
        this.jProgressBarR2.setValue(quality[0]);

        if (iError == FDxError.ERROR_NONE)
        {            
            this.jLabelRegisterImage2.setIcon(new ImageIcon(imgRegistration2.getScaledInstance(130,150,Image.SCALE_DEFAULT)));
            this.jLabelStatus.setText("getImage() Success [" + ret + "]"); 
             
            iError = fplib.getMinutiae(imageBuffer1, regMin2);
            if (iError == FDxError.ERROR_NONE)
            {
               this.jLabelStatus.setText("Second registration image was captured");
               r2Captured = true;
                   System.out.println(regMin1+"que vaina2");
               this.enableRegisterAndVerifyControls();
            }
            else
               this.jLabelStatus.setText("GetMinutiae() Error : " + iError);
         }
         else
            this.jLabelStatus.setText("GetImage() Error : " + iError);
        
        
    }//GEN-LAST:event_jButtonCaptureR2ActionPerformed

    //BOTON CAPTURE R1 ... FALTA
    private void jButtonCaptureR1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButtonCaptureR1ActionPerformed
        // TODO add your handling code here:
        int[] quality = new int[1];
        byte[] imageBuffer1 = ((java.awt.image.DataBufferByte) imgRegistration1.getRaster().getDataBuffer()).getData();
        //byte[] fp_image = new byte[deviceInfo.imageWidth*deviceInfo.imageHeight];
        long iError = FDxError.ERROR_NONE;
         
        iError = fplib.getImage(imageBuffer1);
        int img_qlty = 0;
        
        fplib.getImageQuality(deviceInfo.imageWidth, deviceInfo.imageHeight, imageBuffer1, quality); 
        //progressBar_R1.Value = img_qlty;
        this.jProgressBarR1.setValue(quality[0]);

        if (iError == FDxError.ERROR_NONE)
        {            
            this.jLabelRegisterImage1.setIcon(new ImageIcon(imgRegistration1.getScaledInstance(130,150,Image.SCALE_DEFAULT)));
            this.jLabelStatus.setText("getImage() Success [" + ret + "]"); 
             
            iError = fplib.getMinutiae(imageBuffer1, regMin1);
            if (iError == FDxError.ERROR_NONE)
            {
                this.jLabelStatus.setText("First registration image was captured");
                r1Captured = true;
                System.out.println(regMin1+"que vaina");
                this.enableRegisterAndVerifyControls();
            }
             else
               this.jLabelStatus.setText("GetMinutiae() Error : " + iError);
         }
         else
            this.jLabelStatus.setText("GetImage() Error : " + iError);
        
        
    }//GEN-LAST:event_jButtonCaptureR1ActionPerformed

    private void jButtonCaptureActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButtonCaptureActionPerformed
        // TODO add your handling code here:
        BufferedImage img1gray = new BufferedImage(260, 300, BufferedImage.TYPE_BYTE_GRAY);
        byte[] imageBuffer1 = ((java.awt.image.DataBufferByte) img1gray.getRaster().getDataBuffer()).getData();
        if (fplib != null)
        {
            bLEDOn = !bLEDOn;
            ret = fplib.getImage(imageBuffer1);            
            if (ret == FDxError.ERROR_NONE)
            {
                this.jLabelImage.setIcon(new ImageIcon(img1gray));
                this.jLabelStatus.setText("getImage() Success [" + ret + "]"); 
            }
            else
            {
                this.jLabelStatus.setText("getImage() Error [" + ret + "]");                                
            }
        } 
        else
        {
            this.jLabelStatus.setText("JFPLib is not Initialized");
        }        

    }//GEN-LAST:event_jButtonCaptureActionPerformed

    private void jButtonToggleLEDActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButtonToggleLEDActionPerformed
        // TODO add your handling code here:
        if (fplib != null)
        {
            bLEDOn = !bLEDOn;
            ret = fplib.setLedOn(bLEDOn);
            if (ret == FDxError.ERROR_NONE)
            {
                this.jLabelStatus.setText("setLedOn(" + bLEDOn + ") Success [" + ret + "]");                
            }
            else
            {
                this.jLabelStatus.setText("setLedOn(" + bLEDOn + ") Error [" + ret + "]");                                
            }
        } 
        else
        {
            this.jLabelStatus.setText("JFPLib is not Initialized");
        }        
    }//GEN-LAST:event_jButtonToggleLEDActionPerformed

    //abrir puertos
    private void jButtonInitActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButtonInitActionPerformed
        // TODO add your handling code here
        int selectedDevice = jComboBoxDeviceName.getSelectedIndex();
        //String selectedDeviceText = (String) jComboBoxDeviceName.getSelectedItem();
        switch(selectedDevice)
        {
            case 0: //USB
            case 4: //CN_FDU02
            default:
                this.deviceName = FDxDeviceName.CN_FDU02;
                break;
            case 1: //Parallel
            case 5: //CN_FDP02
                this.deviceName = FDxDeviceName.CN_FDP02;
                break;
            case 2: //CN_FDU01
                this.deviceName = FDxDeviceName.CN_FDU01;
                break;
            case 3: //CN_FDP01
                this.deviceName = FDxDeviceName.CN_FDP01;                
        }
     
        fplib = new JFPLib(this.deviceName);
        if ((fplib != null) && (fplib.jniLoadStatus == FDxError.ERROR_NONE))
        {
            this.jLabelStatus.setText("JFPLib Initialization Success");
            this.devicePort = FDxPortAddr.AUTO_DETECT;
            if ((this.deviceName == FDxDeviceName.CN_FDP02) || (this.deviceName == FDxDeviceName.CN_FDP01))
            {
                switch (this.jComboBoxParallelPort.getSelectedIndex())
                {
                    case 1:
                        this.devicePort = FDxPortAddr.LPT1_378;
                        break;
                    case 2:
                        this.devicePort = FDxPortAddr.LPT2_278;
                        break;
                    case 3:
                        this.devicePort = FDxPortAddr.LPT3_3BC;
                        break;
                }
            }
            if ((this.deviceName == FDxDeviceName.CN_FDU02) || (this.deviceName == FDxDeviceName.CN_FDU01))
            {
                 
                switch (this.jComboBoxUSBPort.getSelectedIndex())
                {
                   
                    case 1:
                    case 2:
                    case 3:
                    case 4:
                    case 5:
                    case 6:
                    case 7:
                    case 8:
                    case 9:
                    case 10:
                        this.devicePort = this.jComboBoxUSBPort.getSelectedIndex() - 1;                       
                        break;
                }
            }
            System.out.println("puerto:"+devicePort);
            ret = fplib.openDevice(devicePort);
            if (ret == FDxError.ERROR_NONE)
            {
                this.jLabelStatus.setText("openDevice() Success [" + ret + "]");       
                ret = fplib.getDeviceInfo(deviceInfo);
                if (ret == FDxError.ERROR_NONE)
                {
                    this.jTextFieldSerialNumber.setText(new String(deviceInfo.deviceSN()));
                    this.jTextFieldBrightness.setText(new String(Integer.toString(deviceInfo.brightness)));
                    this.jTextFieldContrast.setText(new String(Integer.toString((int)deviceInfo.contrast)));
                    this.jTextFieldDeviceID.setText(new String(Integer.toString(deviceInfo.deviceID)));
                    this.jTextFieldFWVersion.setText(new String(Integer.toHexString(deviceInfo.FWVersion)));
                    this.jTextFieldGain.setText(new String(Integer.toString(deviceInfo.gain)));
                    this.jTextFieldImageDPI.setText(new String(Integer.toString(deviceInfo.imageDPI)));
                    this.jTextFieldImageHeight.setText(new String(Integer.toString(deviceInfo.imageHeight)));
                    this.jTextFieldImageWidth.setText(new String(Integer.toString(deviceInfo.imageWidth)));
                    //System.out.println("\tdeviceInfo.ComPort:     [" + deviceInfo.comPort + "]");
                    //System.out.println("\tdeviceInfo.ComSpeed:    [" + deviceInfo.comSpeed + "]");               
                    imgRegistration1 = new BufferedImage(deviceInfo.imageWidth, deviceInfo.imageHeight, BufferedImage.TYPE_BYTE_GRAY);
                    imgRegistration2 = new BufferedImage(deviceInfo.imageWidth, deviceInfo.imageHeight, BufferedImage.TYPE_BYTE_GRAY);
                    imgVerification = new BufferedImage(deviceInfo.imageWidth, deviceInfo.imageHeight, BufferedImage.TYPE_BYTE_GRAY);
                    this.jComboBoxBrightness.setSelectedIndex(deviceInfo.brightness);
                    this.jComboBoxContrast.setSelectedIndex(deviceInfo.contrast);
                    this.jComboBoxGain.setSelectedIndex(deviceInfo.gain-1);
                    this.enableControls();
                    ret = fplib.setContrast(deviceInfo.contrast);
                    if (ret == FDxError.ERROR_NOT_USED)
                    {
                        //Not supported on this platform
                        this.jComboBoxContrast.setEnabled(false);
                        this.jButtonSetContrast.setEnabled(false);
                    }

                }
                else
                    this.jLabelStatus.setText("getDeviceInfo() Error [" + ret + "]");                                
            }
            else
                this.jLabelStatus.setText("openDevice() Error [" + ret + "]");                                
        }
        else
            this.jLabelStatus.setText("JFPLib Initialization Failed");
        
        
    }//GEN-LAST:event_jButtonInitActionPerformed

    private void jComboBoxDeviceNameActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jComboBoxDeviceNameActionPerformed
        // TODO add your handling code here:
    }//GEN-LAST:event_jComboBoxDeviceNameActionPerformed
    
    /** Exit the Application */    
    /**
     * @param args the command line arguments
     */
    public static void main(String args[]) {
        //RILEY new JSGD().show();
        JSGDApplet a = new JSGDApplet(null, true);
                a.setVisible(true);
                
    }
    
    
    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JButton jButtonCapture;
    private javax.swing.JButton jButtonCaptureR1;
    private javax.swing.JButton jButtonCaptureR2;
    private javax.swing.JButton jButtonCaptureV1;
    private javax.swing.JButton jButtonClose;
    private javax.swing.JButton jButtonConfig;
    private javax.swing.JButton jButtonGetDeviceInfo;
    private javax.swing.JButton jButtonInit;
    private javax.swing.JButton jButtonRegister;
    private javax.swing.JButton jButtonSetBrightness;
    private javax.swing.JButton jButtonSetContrast;
    private javax.swing.JButton jButtonSetGain;
    private javax.swing.JButton jButtonToggleLED;
    private javax.swing.JButton jButtonVerify;
    private javax.swing.JComboBox jComboBoxBrightness;
    private javax.swing.JComboBox jComboBoxContrast;
    private javax.swing.JComboBox jComboBoxDeviceName;
    private javax.swing.JComboBox jComboBoxGain;
    private javax.swing.JComboBox jComboBoxParallelPort;
    private javax.swing.JComboBox jComboBoxRegisterSecurityLevel;
    private javax.swing.JComboBox jComboBoxUSBPort;
    private javax.swing.JComboBox jComboBoxVerifySecurityLevel;
    private javax.swing.JLabel jLabelBrightness;
    private javax.swing.JLabel jLabelContrast;
    private javax.swing.JLabel jLabelDeviceID;
    private javax.swing.JLabel jLabelDeviceInfoGroup;
    private javax.swing.JLabel jLabelDeviceName;
    private javax.swing.JLabel jLabelFWVersion;
    private javax.swing.JLabel jLabelGain;
    private javax.swing.JLabel jLabelImage;
    private javax.swing.JLabel jLabelImageDPI;
    private javax.swing.JLabel jLabelImageHeight;
    private javax.swing.JLabel jLabelImageWidth;
    private javax.swing.JLabel jLabelOpenDevice;
    private javax.swing.JLabel jLabelParallel;
    private javax.swing.JLabel jLabelRegisterImage1;
    private javax.swing.JLabel jLabelRegisterImage2;
    private javax.swing.JLabel jLabelRegistration;
    private javax.swing.JLabel jLabelRegistrationBox;
    private javax.swing.JLabel jLabelSecurityLevel;
    private javax.swing.JLabel jLabelSerialNumber;
    private javax.swing.JLabel jLabelSetBrightness;
    private javax.swing.JLabel jLabelSetContrast;
    private javax.swing.JLabel jLabelSetGain;
    private javax.swing.JLabel jLabelSpacer1;
    private javax.swing.JLabel jLabelSpacer2;
    private javax.swing.JLabel jLabelStatus;
    private javax.swing.JLabel jLabelUSBID;
    private javax.swing.JLabel jLabelVerification;
    private javax.swing.JLabel jLabelVerificationBox;
    private javax.swing.JLabel jLabelVerifyImage;
    private javax.swing.JPanel jPanelDeviceInfo;
    private javax.swing.JPanel jPanelImage;
    private javax.swing.JPanel jPanelRegisterVerify;
    private javax.swing.JProgressBar jProgressBarR1;
    private javax.swing.JProgressBar jProgressBarR2;
    private javax.swing.JProgressBar jProgressBarV1;
    private javax.swing.JTabbedPane jTabbedPane1;
    private javax.swing.JTextField jTextFieldBrightness;
    private javax.swing.JTextField jTextFieldContrast;
    private javax.swing.JTextField jTextFieldDeviceID;
    private javax.swing.JTextField jTextFieldFWVersion;
    private javax.swing.JTextField jTextFieldGain;
    private javax.swing.JTextField jTextFieldImageDPI;
    private javax.swing.JTextField jTextFieldImageHeight;
    private javax.swing.JTextField jTextFieldImageWidth;
    private javax.swing.JTextField jTextFieldSerialNumber;
    // End of variables declaration//GEN-END:variables
    
}
